
var logCtrl  = new XFApp.client();
XFApp.client.prototype.log = {
	successCode : "10000",
	urlItems : {
        queryAmtTop : basePath+"/goods/amtTop",
        queryQtyTop : basePath+"/goods/qtyTop"
    },
	showChartA : function(result){
		var myChart = echarts.init(document.getElementById('mainA'));
        var option = {
        	    title : {
        	        text: 'top10品类销售金额(USD)',
        	        x:'center',
        	        padding : 55
        	    },
        	    tooltip : {
        	        trigger: 'item',
        	        formatter: "{a} <br/>{b} : {c} ({d}%)"
        	    },
        	    legend: {
        	        orient : 'vertical',
        	        x : 'left',
        	        y : 'top',
        	        padding : [55,5,5,5],
        	        data:[]
        	    },
        	    toolbox: {
        	        show : true,
        	        feature : {
        	            mark : {show: true},
        	            dataView : {show: true, readOnly: false},
        	            magicType : {
        	                show: true, 
        	                type: ['pie', 'funnel'],
        	                option: {
        	                    funnel: {
        	                        x: '25%',
        	                        width: '50%',
        	                        funnelAlign: 'left',
        	                        max: 1548
        	                    }
        	                }
        	            },
        	            restore : {show: true},
        	            saveAsImage : {show: true}
        	        }
        	    },
        	    calculable : true,
        	    series : [
        	        {
        	            name:'品类销售金额(USD)',
        	            type:'pie',
        	            radius : '55%',
        	            center: ['50%', '60%']
//        	            data:[
//        	            ]
        	        }
        	    ]
        	};
        for(var i = 0; i < result.length; i++){
            option.legend.data.push(result[i].name);
        }
        option.series[0].data=result;
        myChart.setOption(option);
	},
    chartA : function(){
        _this = this;
        $.ajax({
            url:_this.urlItems.queryAmtTop,
            data:$("#searchForm").serialize(),
            type:'get',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.isSuccess){
                    var result = data.result;
                    _this.showChartA(result);
                }
            },
            error : function() {
                window.webDialogUtil.alert("提示","操作失败");
            }
        });
    },
	showChartB : function(result){
		var myChart = echarts.init(document.getElementById('mainB'));
        var option = {
        	    title : {
        	        text: 'top10商品出口',
        	        x:'center',
        	        padding : 55
        	    },
        	    tooltip : {
        	        trigger: 'item',
        	        formatter: "{a} <br/>{b} : {c} ({d}%)"
        	    },
        	    legend: {
        	        orient : 'vertical',
        	        x : 'left',
        	        y : 'top',
        	        padding : [55,5,5,5],
        	        data:[]
        	    },
        	    toolbox: {
        	        show : true,
        	        feature : {
        	            mark : {show: true},
        	            dataView : {show: true, readOnly: false},
        	            magicType : {
        	                show: true, 
        	                type: ['pie', 'funnel'],
        	                option: {
        	                    funnel: {
        	                        x: '25%',
        	                        width: '50%',
        	                        funnelAlign: 'left',
        	                        max: 1548
        	                    }
        	                }
        	            },
        	            restore : {show: true},
        	            saveAsImage : {show: true}
        	        }
        	    },
        	    calculable : true,
        	    series : [
        	        {
        	            name:'商品出口量',
        	            type:'pie',
        	            radius : '55%',
        	            center: ['50%', '60%']
        	        }
        	    ]
        	};
        for(var i = 0; i < result.length; i++){
            option.legend.data.push(result[i].name);
        }
        option.series[0].data=result;
        myChart.setOption(option);
	},
    chartB : function(){
        _this = this;
        $.ajax({
            url:_this.urlItems.queryQtyTop,
            data:$("#searchForm").serialize(),
            type:'get',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.isSuccess){
                    var result = data.result;
                    _this.showChartB(result);
                }
            },
            error : function() {
                window.webDialogUtil.alert("提示","操作失败");
            }
        });
    },
	event : function(){
		_this = this;
		
		$("#searchButton").on("click",function(){
			logCtrl.log.chartA();
			logCtrl.log.chartB();
		});
		this.chartA();
		this.chartB();
	},
};
$(function(){
	logCtrl.log.event();
});